/**
 * @author:albert
 * @date:2016年7月2日
 */
package com.bkbw.live.battle.database.bean;

import java.util.HashMap;
import java.util.List;
import java.util.TreeMap;

import com.bkbw.live.battle.database.DatabaseManager;
import com.bkbw.live.common.util.Utils;

/**
 * @author albert
 *
 */
public class BagBeanManager {
	
	private static BagBeanManager instance = new BagBeanManager();
	public static BagBeanManager getInstance() {
		return instance;
	}
	
	public void dump() {
		for (BagItemBean bagItemBean : hashMap.values()) {
			Utils.dumpSuperObject(bagItemBean);
		}
	}
	
	private TreeMap<Integer, BagItemBean> hashMap = new TreeMap<Integer, BagBeanManager.BagItemBean>();
	
	public TreeMap<Integer, BagItemBean> getMap() {
		return hashMap;
	}
	
	public BagItemBean getBagItemBeanById(int id) {
		return hashMap.get(id);
	}
	
	public BagEquipmentBaseBean getBagEquipmentBaseBeanById(int id) {
		BagItemBean bagItemBean = hashMap.get(id);
		if (bagItemBean instanceof BagEquipmentBaseBean) {
			return (BagEquipmentBaseBean)bagItemBean;
		}
		return null;
	}
	
	public BagEquipmentBean getBagEquipmentBeanById(int id) {
		BagItemBean bagItemBean = hashMap.get(id);
		if (bagItemBean instanceof BagEquipmentBean) {
			return (BagEquipmentBean)bagItemBean;
		}
		return null;
	}
	
	public BagWeaponBean getBagWeaponBeanById(int id) {
		BagItemBean bagItemBean = hashMap.get(id);
		if (bagItemBean instanceof BagWeaponBean) {
			return (BagWeaponBean)bagItemBean;
		}
		return null;
	}
	
	private void extractItemsBean(TreeMap<Integer, ItemsBean> listTreeMap) {
		//TreeMap<Integer, ItemsBean> listTreeMap = DatabaseManager.getInstance().getItemsTable().getTable();
		for (ItemsBean itemsBean : listTreeMap.values()) {
			BagItemBean bagItemBean = new BagItemBean();
			Utils.copySuperFieldsFromBean(bagItemBean, itemsBean);
			hashMap.put(bagItemBean.getId(), bagItemBean);
		}
	}
	
	private void extractEquipmentBean(TreeMap<Integer, EquipmentBean> listTreeMap) {
		//TreeMap<Integer, EquipmentBean> listTreeMap = DatabaseManager.getInstance().getEquipmentTable().getTable();
		for (EquipmentBean equipmentBean : listTreeMap.values()) {
			//Utils.dumpObject(equipmentBean);
			BagEquipmentBean bagEquipmentBean = new BagEquipmentBean();
			Utils.copySuperFieldsFromBean(bagEquipmentBean, equipmentBean);
			hashMap.put(bagEquipmentBean.getId(), bagEquipmentBean);
		}
	}
	
	private void extractWeaponsBean(TreeMap<Integer, WeaponsBean> listTreeMap) {
		//TreeMap<Integer, WeaponsBean> listTreeMap = DatabaseManager.getInstance().getWeaponsTable().getTable();
		for (WeaponsBean weaponsBean : listTreeMap.values()) {
			//Utils.dumpObject(weaponsBean);
			BagWeaponBean bagWeaponBean = new BagWeaponBean();
			Utils.copySuperFieldsFromBean(bagWeaponBean, weaponsBean);
			hashMap.put(bagWeaponBean.getId(), bagWeaponBean);
		}
	}
	
	public void init(TreeMap<Integer, ItemsBean> itemsBeanTreeMap, TreeMap<Integer, EquipmentBean> equipmentBeanTreeMap,
			TreeMap<Integer, WeaponsBean> weaponsBeanTreeMap) 
	{
		extractItemsBean(itemsBeanTreeMap);
		extractEquipmentBean(equipmentBeanTreeMap);
		extractWeaponsBean(weaponsBeanTreeMap);
	}
	
	public static class BagItemBean {
		protected int Id;//
		protected String Name;//
		protected String Icon;//
		protected String Describe;//
		protected int Weight;//
		protected int Quality;//
		protected String Condition;//
		protected int Repeat;//
		protected int ItemType;//
		protected String Param;//
		public int getId(){
			return this.Id;
		}
		public void setId(int Id){
			this.Id=Id;
		}
		public String getName(){
			return this.Name;
		}
		public void setName(String Name){
			this.Name=Name;
		}
		public String getIcon(){
			return this.Icon;
		}
		public void setIcon(String Icon){
			this.Icon=Icon;
		}
		public String getDescribe(){
			return this.Describe;
		}
		public void setDescribe(String Describe){
			this.Describe=Describe;
		}
		public int getWeight(){
			return this.Weight;
		}
		public void setWeight(int Weight){
			this.Weight=Weight;
		}
		public int getQuality(){
			return this.Quality;
		}
		public void setQuality(int Quality){
			this.Quality=Quality;
		}
		public String getCondition(){
			return this.Condition;
		}
		public void setCondition(String Condition){
			this.Condition=Condition;
		}
		public int getRepeat(){
			return this.Repeat;
		}
		public void setRepeat(int Repeat){
			this.Repeat=Repeat;
		}
		public int getItemType(){
			return this.ItemType;
		}
		public void setItemType(int ItemType){
			this.ItemType=ItemType;
		}
		public String getParam(){
			return this.Param;
		}
		public void setParam(String Param){
			this.Param=Param;
		}

	}
	
	public static class BagEquipmentBaseBean extends BagItemBean {
		protected String equipType;

		public String getEquipType() {
			return equipType;
		}

		public void setEquipType(String equipType) {
			this.equipType = equipType;
		}
		
	}
	
	public static class BagEquipmentBean extends BagEquipmentBaseBean {
		
		private String Exclude;//
		private int Armor;//
		private float Sight;//
		private int Hp;//
		private int Evade;//
		private float Speed;//
		private int Endurance;//
		private String Resource;//
		private String EquipEffect;//
		
		public String getExclude(){
			return this.Exclude;
		}
		public void setExclude(String Exclude){
			this.Exclude=Exclude;
		}
		public int getArmor(){
			return this.Armor;
		}
		public void setArmor(int Armor){
			this.Armor=Armor;
		}
		public float getSight(){
			return this.Sight;
		}
		public void setSight(float Sight){
			this.Sight=Sight;
		}
		public int getHp(){
			return this.Hp;
		}
		public void setHp(int Hp){
			this.Hp=Hp;
		}
		public int getEvade(){
			return this.Evade;
		}
		public void setEvade(int Evade){
			this.Evade=Evade;
		}
		public float getSpeed(){
			return this.Speed;
		}
		public void setSpeed(float Speed){
			this.Speed=Speed;
		}
		public int getEndurance(){
			return this.Endurance;
		}
		public void setEndurance(int Endurance){
			this.Endurance=Endurance;
		}
		public String getResource(){
			return this.Resource;
		}
		public void setResource(String Resource){
			this.Resource=Resource;
		}
		public String getEquipEffect(){
			return this.EquipEffect;
		}
		public void setEquipEffect(String EquipEffect){
			this.EquipEffect=EquipEffect;
		}
		@Override
		public String toString() {
			return Utils.getFields(this);
		}
	}
	
	public static class BagWeaponBean extends BagEquipmentBaseBean {
		private float AttackRange;//
		private int AttackPer;//
		private int PenetratePer;//
		private int AttackCountMaxPer;//
		private int HitPer;//
		private int CriPer;//
		private int CriDamagePlus;//
		private int CriSeniorPer;//
		private int CriSeniorDamagePlus;//
		private int AimTime;//
		private int ReloadTime;//
		private int Endurance;//
		private int Sell;//
		private int ShootNum;//
		private int Capacity;//
		private float VisionRange;//
		private String BallGroup;//
		private String ClipGroup;//
		private String BulletShellEffects;//
		private String Resource;//
		private int SkillId;//
		private String Function;//
		private int Angle;//
		private int Attack;//
		private String Effects;//
		private int AttackCount;//
		private int Block;//
		
		public float getAttackRange(){
			return this.AttackRange;
		}
		public void setAttackRange(float AttackRange){
			this.AttackRange=AttackRange;
		}
		public int getAttackPer(){
			return this.AttackPer;
		}
		public void setAttackPer(int AttackPer){
			this.AttackPer=AttackPer;
		}
		public int getPenetratePer(){
			return this.PenetratePer;
		}
		public void setPenetratePer(int PenetratePer){
			this.PenetratePer=PenetratePer;
		}
		public int getAttackCountMaxPer(){
			return this.AttackCountMaxPer;
		}
		public void setAttackCountMaxPer(int AttackCountMaxPer){
			this.AttackCountMaxPer=AttackCountMaxPer;
		}
		public int getHitPer(){
			return this.HitPer;
		}
		public void setHitPer(int HitPer){
			this.HitPer=HitPer;
		}
		public int getCriPer(){
			return this.CriPer;
		}
		public void setCriPer(int CriPer){
			this.CriPer=CriPer;
		}
		public int getCriDamagePlus(){
			return this.CriDamagePlus;
		}
		public void setCriDamagePlus(int CriDamagePlus){
			this.CriDamagePlus=CriDamagePlus;
		}
		public int getCriSeniorPer(){
			return this.CriSeniorPer;
		}
		public void setCriSeniorPer(int CriSeniorPer){
			this.CriSeniorPer=CriSeniorPer;
		}
		public int getCriSeniorDamagePlus(){
			return this.CriSeniorDamagePlus;
		}
		public void setCriSeniorDamagePlus(int CriSeniorDamagePlus){
			this.CriSeniorDamagePlus=CriSeniorDamagePlus;
		}
		public int getAimTime(){
			return this.AimTime;
		}
		public void setAimTime(int AimTime){
			this.AimTime=AimTime;
		}
		public int getReloadTime(){
			return this.ReloadTime;
		}
		public void setReloadTime(int ReloadTime){
			this.ReloadTime=ReloadTime;
		}
		public int getEndurance(){
			return this.Endurance;
		}
		public void setEndurance(int Endurance){
			this.Endurance=Endurance;
		}
		public int getSell(){
			return this.Sell;
		}
		public void setSell(int Sell){
			this.Sell=Sell;
		}
		public int getShootNum(){
			return this.ShootNum;
		}
		public void setShootNum(int ShootNum){
			this.ShootNum=ShootNum;
		}
		public int getCapacity(){
			return this.Capacity;
		}
		public void setCapacity(int Capacity){
			this.Capacity=Capacity;
		}
		public float getVisionRange(){
			return this.VisionRange;
		}
		public void setVisionRange(float VisionRange){
			this.VisionRange=VisionRange;
		}
		public String getBallGroup(){
			return this.BallGroup;
		}
		public void setBallGroup(String BallGroup){
			this.BallGroup=BallGroup;
		}
		public String getClipGroup(){
			return this.ClipGroup;
		}
		public void setClipGroup(String ClipGroup){
			this.ClipGroup=ClipGroup;
		}
		public String getBulletShellEffects(){
			return this.BulletShellEffects;
		}
		public void setBulletShellEffects(String BulletShellEffects){
			this.BulletShellEffects=BulletShellEffects;
		}
		public String getResource(){
			return this.Resource;
		}
		public void setResource(String Resource){
			this.Resource=Resource;
		}
		public int getSkillId(){
			return this.SkillId;
		}
		public void setSkillId(int SkillId){
			this.SkillId=SkillId;
		}
		public String getFunction(){
			return this.Function;
		}
		public void setFunction(String Function){
			this.Function=Function;
		}
		public int getAngle(){
			return this.Angle;
		}
		public void setAngle(int Angle){
			this.Angle=Angle;
		}
		public int getAttack(){
			return this.Attack;
		}
		public void setAttack(int Attack){
			this.Attack=Attack;
		}
		public String getEffects(){
			return this.Effects;
		}
		public void setEffects(String Effects){
			this.Effects=Effects;
		}
		public int getAttackCount(){
			return this.AttackCount;
		}
		public void setAttackCount(int AttackCount){
			this.AttackCount=AttackCount;
		}
		public int getBlock(){
			return this.Block;
		}
		public void setBlock(int Block){
			this.Block=Block;
		}

		@Override
		public String toString() {
			return Utils.getFields(this);
		}
	}
}
